﻿package mortal.game.manager.msgTip
{
    import com.gengine.global.*;
    import com.gengine.utils.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.font.*;
    import mortal.component.gconst.*;
    import mortal.game.manager.*;

    public class MsgFloatWordImpl extends Object
    {
        private var _wordTxt:TextField;
        private var _tweenIn:TweenMax;

        public function MsgFloatWordImpl()
        {
            return;
        }// end function

        public function showWord(param1:String) : void
        {
            this.dispose();
            if (!this._wordTxt)
            {
                this._wordTxt = new TextField();
                this._wordTxt.autoSize = TextFieldAutoSize.CENTER;
                this._wordTxt.defaultTextFormat = new GTextFormat(FontUtil.xingkaiName, 36, 16760832, null, null, null, null, TextFormatAlign.CENTER);
                this._wordTxt.filters = [FilterConst.nameGlowFilter];
                this._wordTxt.selectable = false;
                this._wordTxt.mouseEnabled = false;
                this._wordTxt.width = 1000;
                this._wordTxt.height = 100;
            }
            if (this._wordTxt.parent == null)
            {
                LayerManager.msgTipLayer.addChild(this._wordTxt);
            }
            this._wordTxt.htmlText = HTMLUtil.addColor(param1, "#ffc000");
            this._wordTxt.alpha = 0;
            this._tweenIn = TweenMax.to(this._wordTxt, 1, {alpha:1, ease:Quint.easeIn});
            this.stageResize();
            return;
        }// end function

        public function dispose() : void
        {
            if (this._tweenIn && this._tweenIn.active)
            {
                this._tweenIn.kill();
            }
            if (this._wordTxt)
            {
                this._wordTxt.text = "";
                if (this._wordTxt.parent)
                {
                    this._wordTxt.parent.removeChild(this._wordTxt);
                }
            }
            return;
        }// end function

        public function stageResize() : void
        {
            if (this._wordTxt && this._wordTxt.parent)
            {
                this._wordTxt.x = (Global.stage.stageWidth - this._wordTxt.textWidth) / 2;
                this._wordTxt.y = (Global.stage.stageHeight - this._wordTxt.textHeight) / 2 - 50;
            }
            return;
        }// end function

    }
}
